package com.example.test;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author xiejp on 2022/5/6
 */
public class CallableDemo {
    public static void main(String[] args) throws Exception {
        FutureTask futureTask = new FutureTask(new MyThread());
        new Thread(futureTask,"A").start();
        System.out.println(futureTask.get());

    }
}

class MyThread implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("test");
        return 1024;
    }
}